home *** CD-ROM | disk | FTP | other *** search
/ Aminet 44 / Aminet 44 (2001)(GTI - Schatztruhe)[!][Aug 2001].iso / Aminet / comm / mail / YAM23.lha / YAM2.3 / Rexx / HandleLHA.yam < prev    next >
Text File  |  2000-04-19  |  2KB  |  55 lines

  1. /* HandleLHA.yam - View or extract attached LhA files in YAM          */
  2. /* $VER: HandleLHA.yam 1.1 (21.03.00) © 2000 by M.Beck <mbeck@yam.ch> */
  3. /* Improvements by J. E. Gilpin <jeff-g@hereintown.net>               */
  4. /* Create a new MIME viewer with the following settings:              */
  5. /* Attachment type = application/x-lha                                */
  6. /* Extension       = lha                                              */
  7. /* Viewer          = rx YAM:rexx/HandleLHA.yam %s                     */
  8. /* LhA and RX must be in your AmigaDOS search path                    */
  9.  
  10. PARSE ARG attachmentname
  11. OPTIONS RESULTS
  12. IF ~SHOW(PORTS,'YAM') THEN EXIT
  13. ADDRESS YAM
  14. 'Info VAR screenname SCREEN'
  15. console='CON:/33//200/HandleLHA/WAIT/CLOSE/SCREEN'||screenname
  16.  
  17. 'Request BODY "What shall I do with this archive?" GADGETS "View contents|Extract files|Save archive|Cancel"'
  18. choice = RESULT
  19. IF choice=1 THEN ADDRESS COMMAND 'LhA >'console' v 'attachmentname
  20.  
  21. ELSE IF choice=2 THEN DO
  22.   ADDRESS COMMAND 'RequestFile >T:destdir.string DRAWERSONLY DRAWER=RAM: TITLE="Select a destination directory" SAVEMODE PUBSCREEN='screenName' '
  23.   IF RC=0 THEN DO
  24.     IF OPEN(IN,'T:destdir.string','R') THEN DO
  25.       destdir = STRIP(READLN(IN),'B','"')
  26.       CALL CLOSE(IN)
  27.       IF EXISTS(destdir) THEN ADDRESS COMMAND 'LhA >'console' x 'attachmentname' 'DestDir
  28.     END
  29.   END
  30.   IF EXISTS('T:destdir.string') THEN ADDRESS COMMAND 'Delete >NIL: "T:destdir.string"'
  31. END
  32.  
  33. ELSE IF Choice=3 THEN DO
  34.   Information. = 0
  35.   'ReadInfo STEM ri.'
  36.   IF ri.TEMPFILE.COUNT < 1 THEN EXIT
  37.   name = STRIP(attachmentname,'B','"')
  38.   DO cnt=1 TO ri.TEMPFILE.COUNT
  39.     IF ri.TEMPFILE.cnt = name THEN realname = ri.FILENAME.cnt
  40.   END
  41.   ADDRESS COMMAND 'RequestFile >T:dest.string FILE='realname' DRAWER=RAM: TITLE="Select a directory and filename" SAVEMODE PUBSCREEN='screenname' '
  42.   IF RC=0 THEN DO
  43.     IF OPEN(IN,'T:dest.string','R') THEN DO
  44.       destpath = STRIP(READLN(IN),'B','"')
  45.       CALL CLOSE(IN)
  46.       length = LASTPOS('/',destpath)
  47.       IF length=0 THEN length = LASTPOS(':',destpath)
  48.       IF length~=0 THEN DO
  49.         IF EXISTS(LEFT(destpath,length)) THEN ADDRESS COMMAND 'Copy 'attachmentname' 'destpath
  50.       END
  51.     END
  52.   END
  53.   IF EXISTS('T:dest.string') THEN ADDRESS COMMAND 'Delete >NIL: "T:dest.string"'
  54. END
  55.